package com.miracle.travel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.miracle.travel.domain.TravelSceneryInfo;
import com.miracle.travel.service.ITravelSceneryInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 景点信息Controller
 * 
 * @author miracle
 * @date 2023-04-24
 */
@RestController
@RequestMapping("/travel/scenery")
public class TravelSceneryInfoController extends BaseController
{
    @Autowired
    private ITravelSceneryInfoService travelSceneryInfoService;

    /**
     * 查询景点信息列表
     */
    @PreAuthorize("@ss.hasPermi('travel:scenery:list')")
    @GetMapping("/list")
    public TableDataInfo list(TravelSceneryInfo travelSceneryInfo)
    {
        startPage();
        List<TravelSceneryInfo> list = travelSceneryInfoService.selectTravelSceneryInfoList(travelSceneryInfo);
        return getDataTable(list);
    }

    /**
     * 导出景点信息列表
     */
    @PreAuthorize("@ss.hasPermi('travel:scenery:export')")
    @Log(title = "景点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelSceneryInfo travelSceneryInfo)
    {
        List<TravelSceneryInfo> list = travelSceneryInfoService.selectTravelSceneryInfoList(travelSceneryInfo);
        ExcelUtil<TravelSceneryInfo> util = new ExcelUtil<TravelSceneryInfo>(TravelSceneryInfo.class);
        util.exportExcel(response, list, "景点信息数据");
    }

    /**
     * 获取景点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:scenery:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(travelSceneryInfoService.selectTravelSceneryInfoById(id));
    }

    /**
     * 新增景点信息
     */
    @PreAuthorize("@ss.hasPermi('travel:scenery:add')")
    @Log(title = "景点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelSceneryInfo travelSceneryInfo)
    {
        return toAjax(travelSceneryInfoService.insertTravelSceneryInfo(travelSceneryInfo));
    }

    /**
     * 修改景点信息
     */
    @PreAuthorize("@ss.hasPermi('travel:scenery:edit')")
    @Log(title = "景点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelSceneryInfo travelSceneryInfo)
    {
        return toAjax(travelSceneryInfoService.updateTravelSceneryInfo(travelSceneryInfo));
    }

    /**
     * 获取景点地图数据
     */
    // @PreAuthorize("@ss.hasPermi('travel:scenery:list')")
    @GetMapping("/getMapData")
    public List<TravelSceneryInfo> getMapData()
    {
        List<TravelSceneryInfo> list = travelSceneryInfoService.getMapData();
        return list;
    }


}
